<div class="wrapper">
    <h1>类目列表：</h1>
    <table cellpadding="0" cellspacing="0" border="0" width="800" >
        <thead>
            <tr>
                <th width="20%">序号</th>
                <th width="30%">名称</th>
                <th width="20%">排序</th>
                <th width="30%">操作</th>
            </tr>            
        </thead>
        <tbody>
            <?php if(!empty($category)):?>
            <?php foreach($category as $list):?>
            <tr>
                <td><?php echo $list['cid'];?></td>
                <td><?php echo $list['cname'];?></td>
                <td><?php echo $list['order'];?></td>
                <td><a href="javascript:void(0)" class="a_btn">编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" class="a_btn">删除</a></td>
            </tr>
            <?php endforeach;?>
            <?php endif;?>
        </tbody>
    </table>
    <h1>添加新类目：</h1>
    <ul>
        <li><span>类目名称：</span><input type="text" name="cname" value="" class="ipt_blank" /><a class="red">*</a></li>
        <li><span>类目排序：</span><input type="text" name="order" value="" class="ipt_blank" /><a class="red">*</a></li>
        <li><span></span><a href="javascript:void(0)" class="a_btn add_category">保存</a><a class="red alter"></a></li>
    </ul>
</div>
<script type="text/javascript">
    $(".add_category").click(function(){
        var cname = $("input[name=cname]").val();
        var order = $("input[name=order]").val();
        
        if(cname == '' || cname == null || cname.length == 0) {
            _alert("请输入类目名称");
            $("input[name=cname]").focus();
            return false;
        }
        
        if(order == '' || order == null || order.length == 0) {
            _alert("请输入类目排序");
            $("input[name=order]").focus();
            return false;
        }
        
        var data = {cname:cname,order:order};
        var url = "/index.php?c=admin&m=addCategory";
        var res = _ajax(url,data);
        _ajax_alert(res);
    });
</script>







